<template>
  <div>
    <card style="margin-bottom: 10px" v-if="$store.state.superAdmin == 'true'">
      <el-select
        style="width: 100%"
        v-model="museumId"
        @change="change"
        filterable
        placeholder="请选择博物馆"
      >
        <el-option
          v-for="item in museumList"
          :key="item.id"
          :label="item.name"
          :value="item.id"
        >
        </el-option>
      </el-select>
    </card>
    <Card>
      <Table
        class="table"
        :loading="loading1"
        highlight-row
        :columns="columns"
        :data="data"
      ></Table>
      <Page
      show-total
        class="page"
        :total="total"
        :current.sync="current"
        show-elevator
        @on-change="changePage"
      />
    </Card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      clearable: false,
      loading1: false,
      loading2: false,
      columns: [
        { title: "昵称", key: "nickName", align: "center" ,   minWidth: 200,},
        { title: "用户标识", key: "openid", align: "center" ,   minWidth: 400,},
        { title: "手机号", key: "phone", align: "center",   minWidth: 200, },
        {
          title: "锁定天数",
          key: "lockDay",
          align: "center",
          minWidth: 100,
        },
        {
          title: "释放时间",
          key: "releaseTime",
          align: "center",
		     minWidth: 200,
        },
        {
          title: "操作",
          align: "center",
          width: 200,
          render: (h, params) => {
            return h("div", [
              h(
                "Button",
                {
                  props: {
                    type: "success",
                  },
                  style: {
                    marginRight: "10px",
                  },
                  on: {
                    click: () => {
                      this.toblack(params);
                    },
                  },
                },
                "移出黑名单"
              ),
            ]);
          },
        },
      ],
      museumId: "",
      museumList: [],
      data: [],
      total: 0,
      current: 1,
      modal: false,
      id: "",
      time: [],
      newData: {},
      imgUrl: "",
      clear: false,
      bannerType: [],
    };
  },
  created() {
    if (this.$store.state.superAdmin == "true") {
      this.getmuseumList();
    } else {
      if (this.$store.state.museums.length > 1) {
        this.museumId = this.$store.state.museumId;
		this.findBannerPager();
      } else {
        this.museumId = "";
      }
      this.getDay();
    }
    this.getBannerPlatformType();
  },
  methods: {
    getmuseumList() {
      this.spinShow1 = true;
      this.spinShow3 = true;
      this.$http("/stage/museum/getAppMuseumDropDown", {}, "post", (res) => {
        if (res.data.code == 200) {
          this.museumList = res.data.data;
          for (let i = 0; i < this.museumList.length; i++) {
            if (this.museumList[i].name.length > 50) {
              this.museumList[i].name =
                this.museumList[i].name.slice(0, 50) + "...";
            }
          }
          this.museumId = this.museumList[0].id;
          this.findBannerPager();
        } else {
          this.$Message.error(res.data.msg);
        }
      });
    },
    getBannerPlatformType() {
      this.loading1 = true;
      this.$http("/stage/banner/getBannerPlatformType", {}, "get", (res) => {
        if (res.data.code == 200) {
          this.bannerType = res.data.data;
          this.findBannerPager();
        }
      });
    },
    change() {
      console.log(this.museumId);
      this.current = 1;
      this.findBannerPager();
    },
    getBannerPlatformType() {
      this.loading1 = true;
      this.$http("/stage/banner/getBannerPlatformType", {}, "get", (res) => {
        if (res.data.code == 200) {
          this.bannerType = res.data.data;
          this.findBannerPager();
        }
      });
    },
    changePage(e) {
      this.current = e;
      this.findBannerPager();
    },
    findBannerPager() {
      this.loading1 = true;
      console.log(this.current);

      this.$http(
        "/stage/warning/getBookBlackList",
        {
          current: this.current,
          museumId: this.museumId,
          size: 10,
        },
        "post",
        (res) => {
          if (res.data.code == 200) {
            this.data = res.data.data.records;
            this.total = res.data.data.total;
          } else {
            this.$Message.error(res.data.msg);
          }
          this.loading1 = false;
        }
      );
    },
    toblack(params) {
      console.log(params.row);
      this.$http(
        "/stage/warning/removeBlackList",
        {
          id: params.row.id,
        },
        "get",
        (res) => {
          if (res.data.code == 200) {
            console.log(res.data);
            this.$Message.success("成功移出黑名单");
            this.findBannerPager();
          } else {
            this.$Message.error(res.data.msg);
          }
          this.loading1 = false;
        }
      );
    },
  },
};
</script>

<style scoped>
</style>